import React,{Component} from 'react';
import { Form, Input, Button, Radio, Menu, Dropdown, Icon, message } from 'antd';
import { Link, history} from 'react-router-dom';
import './index.less';
import axios from "axios";
import { connect } from "react-redux";
const { TextArea } = Input;
axios.defaults.headers.post['Content-Type'] = 'application/json;charset=UTF-8';

const Token = localStorage.getItem("token");
class downloadCertificate extends React.Component {
	constructor(props){
		super(props)
		this.state = {
		}
	}

	getCertId=()=>{
		// console.log(this.props)
		// console.log(this.props.DownLoad)
		setTimeout(()=>{
			if(this.props.getCertId){
				this.props.getCertId
			}
		})
	}


	componentWillMount(){
		this.getCertId();
	}

	render(){

		return <div className="subTopBox">
        <div className="subTopBox-hd">
          <div className="hd-title">
            <span className="step active">
              <i>1</i>
              创建秘钥
            </span>
            <em className="line active" />
            <span className="step active">
              <i>2</i>
              创建证书
            </span>
            <em className="line active" />
            <span className="step active">
              <i>3</i>
              下载证书
            </span>
          </div>
        </div>
        <div className="createSuccess">
          <h3 className="lastSteps">证书生成成功！</h3>
          <p className="Item_1">您的证书已经成功创建！</p>
          <p className="Item_2">
            您可以在“账户服务-证书管理”中使用管理你所创建的所有证书。
          </p>
          <div className="btns">
            <a href={"/api/block/baas/Ca/downloadFileCa?id=" + this.props.getCertId + "&token=" + Token} className="download">
              下载证书
            </a>
            <Link to="/certificateManagement">
              <Button type="primary" htmlType="submit">
                确认
              </Button>
            </Link>
          </div>
        </div>
      </div>;
	}
}

export default connect((state) => {
    return { ...state };
  })(downloadCertificate);
